import turtle


def func_a():
    turtle.penup()


def func_b():
    turtle.pendown()


def func_click(x, y):
    if x> 230:
        if y>175 and y <225:
            turtle.pencolor(colours[0])
        elif y >95 and y < 145:
            turtle.pencolor(colours[1])
        elif y >15 and y < 65:
            turtle.pencolor(colours[2])
    else:
        turtle.goto(x, y)



colours = ["red", "yellow", "green"]
h = [(260, 200), (260, 120), (260, 40)]
for i in range(3):
    turtle.penup()
    turtle.goto(h[i])
    turtle.pendown()
    turtle.dot(50, colours[i])
turtle.up()
turtle.goto(0, 0)
turtle.pendown()

turtle.onscreenclick(func_click, 1)
turtle.onkeypress(func_a, "u")
turtle.onkeypress(func_b, "d")
turtle.listen()
turtle.dot()
turtle.done()
